package cn.eweb.util;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

public class Tools {
	/**
     * 判断网络连接
     * @param context android应用程序的全局信息
     * @return boolean true=成功 false=失败
     */
    public static boolean isNetWorkAvailable(Context context) {
		if (context == null) {
			return false;
		}

		ConnectivityManager connectivityManager = (ConnectivityManager) context
				.getSystemService(Context.CONNECTIVITY_SERVICE);
		NetworkInfo activeNetInfo = connectivityManager.getActiveNetworkInfo();
		if (activeNetInfo != null && activeNetInfo.isAvailable() && activeNetInfo.isConnected()) {
			return true;
		} else {
			return false;
		}
	}
}
